<?php
require_once 'vendor/autoload.php';

// 初始化应用
$app = new \think\App();
$app->initialize();

use think\facade\Db;

try {
    echo "检查orders表数据...\n";
    
    // 获取订单总数
    $total = Db::table('orders')->count();
    echo "订单总数: $total\n";
    
    if ($total > 0) {
        // 获取最近的5个订单
        $orders = Db::table('orders')->order('created_at', 'desc')->limit(5)->select();
        
        echo "\n最近的订单详情:\n";
        foreach ($orders as $order) {
            echo "ID: {$order['id']}\n";
            echo "订单号: {$order['order_no']}\n";
            echo "平台: {$order['platform']}\n";
            echo "订单日期: {$order['order_date']}\n";
            echo "客户姓名: {$order['customer_name']}\n";
            echo "商品名称: {$order['product_name']}\n";
            echo "数量: {$order['quantity']}\n";
            echo "单价: {$order['unit_price']}\n";
            echo "总金额: {$order['total_amount']}\n";
            echo "成本价: {$order['cost_price']}\n";
            echo "利润: {$order['profit']}\n";
            echo "状态: {$order['status']}\n";
            echo "同步日期: {$order['sync_date']}\n";
            echo "创建时间: {$order['created_at']}\n";
            echo "---\n";
        }
    } else {
        echo "orders表中没有数据\n";
    }
    
} catch (Exception $e) {
    echo "错误: " . $e->getMessage() . "\n";
} 